<%@ tag pageEncoding="utf-8"%>
<!-- 声明JSTL标签，以便在本标签中使用 -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- 定义了两个标签属性 -->
<%@ attribute name="formID" required="true" rtexprvalue="true" description="搜索条件提交的表单ID"%>

<%@ attribute name="numPerPage" required="false" rtexprvalue="true" type="java.lang.Integer" description="每页显示条数"%>
<%@ attribute name="isShowpageCount" required="false" rtexprvalue="true" type="java.lang.Boolean" description="是否显示总页数"%>
<%@ attribute name="isShowJumpToButton" required="false" rtexprvalue="true" type="java.lang.Boolean" description="是否显示跳转按钮"%>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/css/webform.css?v=20180104" />
<script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/jquery.1.11.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/jquery.select-1.3.6.js"></script>
<style>
<%-- 分页样式 --%>
</style>
<div class="cz_bottom">
	<div class="left">
		<p>当前${pageBean.startRowNum } - ${pageBean.endRowNum } 条 共计 ${pageBean.totalCount} 条</p>
	</div>
	<div class="center"  style="margin-right: 20px;">
		<p>
			<c:if test="${pageBean.currentPage == 1 }">
				<a>首页</a> 
				<a>上一页</a> 
			</c:if>
			<c:if test="${pageBean.currentPage > 1 }">
				<a href="javascript:;" onclick="getLink(1)">首页</a> 
				<a href="javascript:;" onclick="getLink(${pageBean.currentPage - 1})">上一页</a> 
			</c:if>
			<%-- <a href="#" class="current">${pageBean.currentPage}</a>  --%>
			<c:forEach items="${pageBean.pageItems}" var="pageItem">
				<c:if test="${empty pageItem }">
					<a href="javascript:;">...</a>
				</c:if>
				<c:if test="${pageItem != null and pageItem == pageBean.currentPage}">
					<a href="javascript:;" class="current">${pageItem}</a>
				</c:if>
				<c:if test="${pageItem != null and pageItem != pageBean.currentPage}">
					<a href="javascript:;" onclick="getLink(${pageItem});">${pageItem}</a>
				</c:if>
				</li>
			</c:forEach>
			<c:if test="${pageBean.currentPage == pageBean.pageCount }">
				<a>下一页</a> 
				<a>尾页</a> 
			</c:if>
			<c:if test="${pageBean.currentPage < pageBean.pageCount }">
				<a href="javascript:;" onclick="getLink(${pageBean.currentPage + 1})">下一页</a>
				<a href="javascript:;" onclick="getLink(${pageBean.pageCount})">尾页</a>
			</c:if>
			<input id="btn_go_input" type="text" class="inputstyle11" style="width:40px;" value="${pageBean.currentPage}" placeholder="跳转页数"> 
			<input id="btn_go" type="button" class="inputbtn2" value="确定">
			<c:set var="pageSize" value="${numPerPage }"></c:set>
			<c:choose>
				<c:when test="${not empty numPerPage }">
					<c:set var="pageSize" value="${numPerPage }"></c:set>
				</c:when>
				<c:otherwise>
					<c:set var="pageSize" value="${pageBean.numPerPage }"></c:set>
				</c:otherwise>
			</c:choose>
			<input type="hidden" name="numPerPage" id="select_numPerPage" value="${pageSize }">
		</p>
	</div>
</div>

<script type="text/javascript">
$(function(){
	//$(".page_selector").sSelect();
	$('.del_part p input,#delbox .hd span a,#delbox .bottom  p input').click(function(){$('#delbox').toggle();});
	//当前页码
	var currentPage = ${pageBean.currentPage};
	//总页码  
	var pageCount = ${pageBean.pageCount};
	//总数据条数  
    var totalCount = ${pageBean.totalCount};
	//--------function in input text to jump into the page-------------//
	$("#btn_go_input").blur(function(){
		validateInputPageNO()
	});
	$("#btn_go").click(function(){
		validateInputPageNO();
	});
	
	$("#select_numPerPage").change(function(){
		var currentValue=$(this).val();
		getLink(1);
	});
});

// 页面跳转
function getLink(n){
	var $form = $("#${formID}");
	var tmp_currentPage = '<input type="hidden" name="tmpCurrentPage" value="'+n+'"/>';
	var tmp_numPerPage = '<input type="hidden" name="tmpNumPerPage" value="'+$("#select_numPerPage").val()+'"/>';
	$form.append(tmp_currentPage);
	$form.append(tmp_numPerPage);
	$form.submit();
}

// 验证跳转页硕必须是数字
function validateInputPageNO(){
	var str_page = $("#btn_go_input").val();  
   	if(isNaN(str_page)){
       	$("#btn_go_input").val(1);
    	return;
   	}
   	var n = parseInt(str_page);  
	if(n > ${pageBean.pageCount}){
   		n = ${pageBean.pageCount};
   	}
	getLink(n);
}
</script>
